<?php

namespace App\Http\Controllers\Callback\Payment;

use App\Helpers\LogHelper;
use App\Http\Controllers\Callback\BaseCallbackController;
use App\Services\Callback\Payment\WechatPaymentService;
use Exception;

class WechatPaymentController extends BaseCallbackController
{

    protected WechatPaymentService $wechatPaymentService;

    /**
     * @throws Exception
     */
    public function __construct()
    {
        parent::__construct();
        $this->wechatPaymentService = $this->loadService('Callback\Payment\WechatPaymentService');
    }

    /**
     * 回调
     * @return void
     */
    public function callback()
    {
        LogHelper::info('callback', ['params' => $this->params]);
        try {
            $this->wechatPaymentService->callback($this->params);
            echo "SUCCESS";
        } catch (Exception $exception) {
            LogHelper::error('callback', $exception);
            echo "FAIL";
        }
    }
}
